package master

import (
	"encoding/json"
	"io/ioutil"
)

type Config struct {
	ApiPort          int      `json:"apiPort"`
	ApiReadTimeout   int      `json:"apiReadTimeout"`
	ApirWriteTimeout int      `json:"apiWriteTimeout"`
	EtcdEndpoints    []string `json:"etcdEndpoints"`
	EtcdDialTimeout  int      `json:"etcdDialTimeout"`
	WebRoot          string   `json:"webroot"`
}

var G_config *Config

// 加载配置
func InitConfig(filename string) (err error) {
	// var content []byte
	content, err := ioutil.ReadFile(filename)
	if err != nil {
		return
	}
	err = json.Unmarshal(content, &G_config)
	if err != nil {
		return
	}
	return nil
}
